<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      margin: 0 auto;
      padding: 0;
    }
    .box ul {
      width: 540px;
      display: flex;
      flex-wrap: wrap;
      margin: 20px auto;
    }
    .box ul li {
      list-style: none;
      width: 100px;
      height: 100px;
      margin: 0 10px 10px 0;
    }
  </style>
</head>
<body>
  <div class="box">
    <ul>
      <script>
        let images = [
          './images/1.webp',
          './images/2.webp',
          './images/3.webp',
          './images/4.webp',
          './images/5.webp',
          './images/6.webp',
          './images/7.webp',
          './images/8.webp',
          './images/9.webp',
          './images/10.webp',
          './images/11.webp',
          './images/12.webp',
          './images/13.webp',
          './images/14.webp',
          './images/15.webp',
          './images/16.webp',
          './images/17.webp',
          './images/18.webp',
          './images/19.webp',
          './images/20.webp'
        ]
        let num = +prompt('请输入显示的英雄1-20之间：')
        for (let i = 0; i < num; i++) {
          document.write(`
            <li>
              <img src="${images[i]}" alt="">
            </li>
          `)
        }
      </script>
    </ul>
  </div>
  
</body>
</html>